<template>
  <select-dept-modal ref="selectDept" @on-ok="onOK" />
</template>

<script>
  import SelectDeptModal from '../components/SelectDeptModal';
  import { moveUser } from '@/api/organization';

  export default {
    components: { SelectDeptModal },
    data() {
      return {
        // visible: false,
        selectedIds: [],
      };
    },
    methods: {
      onOpen(data) {
        const { selectedIds } = data;
        this.selectedIds = selectedIds;
        this.$refs['selectDept'].show();
      },
      async onOK(item) {
        await moveUser({
          staffIds: this.selectedIds,
          deptId: item.id,
        });
        this.$emit('moved');
      },
    },
  };
</script>
<style lang="scss" scoped></style>
